﻿Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Seuss.EnterpriseLibrary.DataAccess
Imports Seuss.EnterpriseLibrary.BusinessLogic
Imports System.Web
Imports System.Data

Partial Class Consulta_DO_Horario
    Inherits System.Web.UI.Page
    Dim cPerJuridica As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.Expires = -1
        Response.AddHeader("Pragma", "no-cache")
        Response.AddHeader("cache-control", "private")
        Response.CacheControl = "no-cache"       

        If Not Page.IsPostBack Then            
            Call CargarHorario()
            Using Seguridad As New BLL_Administracion
                Seguridad.Set_Transaccion_Insert(Nothing, 100401, IdentityUser.UserCode, My.Request.UserHostAddress.ToString, CrearXMLTransaccion("Consulta Pagina Movil", "/Pagina|" + My.Request.Url.Segments(My.Request.Url.Segments.Length - 1).ToString))
            End Using
        End If
    End Sub

    Private Sub CargarHorario()
        Dim ldr As New List(Of IDataReader)
        Dim DivPrincipal As New StringBuilder
        Dim DivEscuela As New StringBuilder
        Dim Escuela As String = ""
        Dim Asignatura As String = ""

        DivPrincipal.Append("<table border=0 width='100%'>")

        Using ObjPool As New PoolDbCommand()
            Dim ObjUsuario As New DAL_Kiosco(ObjPool.Database)
            ObjPool.AddDbCommand(ObjUsuario.Get_HorarioDocente_By_cPerCodigo(IdentityUser.UserCode), PoolDbCommand.PoolDbCommandResultType.Query)
            ObjPool.Pooling(Nothing, ldr, True)
            ObjUsuario = Nothing
            While ldr(0).Read
                If Escuela <> ldr(0).Item("cUniOrgAbrev").ToString Then
                    DivPrincipal.Append("<tr style='color:#FFFFFF'>")
                    DivPrincipal.Append("   <td style='font-size:12px;color:#000000; text-align:left;font-weight :bold' colspan='5'><img src='../Imagenes/Ok2.gif' />Escuela de " + ldr(0).Item("cUniOrgAbrev").ToString + "</td>")
                    DivPrincipal.Append("</tr>")
                End If

                If Asignatura <> ldr(0).Item("Observ").ToString Then
                    DivPrincipal.Append("<tr style='color:#FFFFFF'>")
                    DivPrincipal.Append("   <td style='background-color:#666666;font-size:11px;' colspan='5'>" + ldr(0).Item("Observ").ToString + " - Sec. " + ldr(0).Item("seccion").ToString + "</td>")
                    DivPrincipal.Append("</tr>")
                End If

                DivPrincipal.Append("<tr>")
                DivPrincipal.Append("   <td style='font-size:9px;width:8%;'>E: " + ldr(0).Item("dHorInicio").ToString + "</td>")
                DivPrincipal.Append("   <td style='font-size:9px;width:8%;'>S: " + ldr(0).Item("dHorFin").ToString + "</td>")
                DivPrincipal.Append("   <td style='font-size:9px;width:14%;'>" + ldr(0).Item("Ambiente").ToString + "</td>")
                DivPrincipal.Append("</tr>")

                Escuela = ldr(0).Item("cUniOrgAbrev").ToString
                Asignatura = ldr(0).Item("Observ").ToString
            End While
        End Using

        DivPrincipal.Append("</table>")
        lblHorario.Text = DivPrincipal.ToString
    End Sub

End Class
